<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Vote
 * @copyright  Copyright KEENONWEB LLC
 * @license    http://www.keenonweb.com/
 * @version    $Id: Participate.php 2011-03-09 08:45:41Z idris $
 * @author     Idris
 */

/**
 * @category   Application_Extensions
 * @package    Vote
 * @copyright  Copyright KEENONWEB LLC
 * @license    http://www.keenonweb.com/
 */

class Vote_Form_Video_Participate extends Vote_Form_Participate {
	public function init() {
		parent::init ();
		
		$subject = Engine_Api::_ ()->core ()->getSubject ();
		
		$this->setTitle ( 'vote_video_part_CREATE_TITLE' )->setDescription ( 'vote_video_part_CREATE_DESC' )->setMethod ( 'post' )->setAttrib ( 'id', 'form-upload' )->setAttrib ( 'class', 'global_form create_voting_form' )->setAction ( Zend_Controller_Front::getInstance ()->getRouter ()->assemble ( array ('controller' => 'video', 'action' => 'upload', 'challenge_id' => $subject->getIdentity () ), 'vote_general' ) );
		
		$this->getElement ( 'title' )->setLabel ( 'vote_video_part_Title' );
		$this->getElement ( 'description' )->setLabel ( 'vote_video_part_Description' );
		
		$this->removeElement ( 'photo' );
		$this->removeDisplayGroup ( 'buttons' );
		
		$this->addElement ( 'Select', 'video_type', array ('label' => 'Video Source', 'multiOptions' => array ('0' => ' ' ), 'onchange' => "updateTextFields()" ) );
		
		$video_options = Array ();
		$video_options [1] = "YouTube";
		$video_options [2] = "Vimeo";
		
		$ffmpeg_path = Engine_Api::_ ()->getApi ( 'settings', 'core' )->video_ffmpeg_path;
		if (! empty ( $ffmpeg_path )) {
			$video_options [3] = "My Computer";
		}
		$this->video_type->addMultiOptions ( $video_options );
		
		$this->addElement ( 'Text', 'url', array ('label' => 'Video Link (URL)', 'description' => 'Paste the web address of the video here.', 'maxlength' => '50', 'order' => 120 ) );
		$this->url->getDecorator ( "Description" )->setOption ( "placement", "append" );
		
		$this->addElement ( 'Hidden', 'code', array ('order' => 1 ) );
		$this->addElement ( 'Hidden', 'id', array ('order' => 2 ) );
		$this->addElement ( 'Hidden', 'ignore', array ('order' => 3 ) );
		
		$fancyUpload = new Engine_Form_Element_FancyUpload ( 'file' );
		$fancyUpload->clearDecorators ()->addDecorator ( 'FormFancyUpload' )->addDecorator ( 'viewScript', array ('viewScript' => '_FancyUpload.tpl', 'placement' => '' ) );
		
		Engine_Form::addDefaultDecorators ( $fancyUpload );
		$this->addElement ( $fancyUpload );
		
		$this->removeElement ( 'submit' );
		$this->removeElement ( 'cancel' );
		
		// Init submit
		$this->addElement ( 'Button', 'upload', array ('label' => 'Save Video', 'type' => 'submit', 'order' => 100000 ) );
	}
}